// 
// File:   MyGraphClass.h
// Author: ben
//
// Created on April 28, 2008, 12:52 AM
//

#ifndef _MYGRAPHCLASS_H
#define	_MYGRAPHCLASS_H

#include <vector>
#include <queue>
#include <stack>
#include <math.h>

#include <iostream>
#include <string>
#include <fstream>
#include <sstream>




#include "MyVertexClass.h"
#include "xmlreader.h"
enum {
    NOTHING_TODO,
    MULTIPLY_K,
    LAST_LEARN
};

/*
const char *LEARNING_STR[]={
    "multiply by rate" };
 **/
string LEARNING_STR(int i);


using namespace std;

typedef class MyGraph{
public:
    MyGraph(int Givesize);
    MyGraph(){MyGraph(0);};
    ~MyGraph();
    void AddConnection(int iFrom,int iTo,double dweight);
    void ShowVertices();
    int NumberVertices(){return(VVertices.size());};
    void ExploreQueue();
    void ExploreQueue(int FirstVertex);
    void ExploreStack();
    void ExploreStack(int FirstVertex);
    void ClearMarker();
    
    int LoadLinks(string fname);
    int LoadNames(string fname);
    int LoadXml(string spath,string sfname,string fname_w);
    
    int ProduceDotFile();
    
    string NameForDot(int i);
    
    int SortNext(int inode,bool Permute);
    int SortNext();
    int getNext(int inode,int nextnum);
    
    string getName(int i);
    
    int Learn(int i_0,int i_1,int i_k);
    int LearnXml(int i_0, int i_1, int i_k,int method);
    int WriteXmlW(string fname);

    int Reload();
    int ReloadXml();
    //int Generate();

    int Resize(int n);

    int SaveWeights(string fname);
    
private:
    int PrivateLoader();
    double ChangeIt(bool isTrue,double current,int method);
    void ShowQueue(std::queue<int> TheQueue);
    void ShowStack(std::stack<int> TheStack);
    std::vector<MyVertex> VVertices;
    
    string thisfname_links;
    string thisfname_names;
    //string thispath;
    //string thisfname;
    XmlReader *myreader;
}MyGraph;

#endif	/* _MYGRAPHCLASS_H */

